﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace BaoVeBienCuong.Playgame.enemy
{
    class Coin
    {
        private int Value;// giá trị của đồng tiền
        private Texture2D image; // ảnh chứa tiền
        private Vector2 position; // vị trí vẽ ảnh
        private Vector2 index; // vị trí của đồng tiền
        private Vector2 size = new Vector2(54, 67);
        private bool isVisible;
        int i;
        public Coin(int val, Vector2 index)
        {
            isVisible = true;
            i = 0;
            Value = val;
            this.index = index;
            Vector2 size = new Vector2(GamePage.sizeImageBackGround.X / GamePage.sizeMap.Y, GamePage.sizeImageBackGround.Y / GamePage.sizeMap.X);
            position = new Vector2(index.Y * size.X, index.X * size.Y);
        }
        public void Load(ContentManager cont)
        {
            image = cont.Load<Texture2D>("images/enemys/gold");
        }
        public void Draw(SpriteBatch sprite)
        {
            if (isVisible)
            {
                sprite.Draw(image, (position + new Vector2(50, 50)) * GamePage.scale + GamePage.DoLech, new Rectangle(54 * ((i % 20) / 5), 0, 54, 67), Color.White, 0, Vector2.Zero, GamePage.scale, SpriteEffects.None, 0);
                i++;
                if (i == 150) isVisible = false;
            }
        }
        public bool isTouch(Vector2 posi)
        {
            if (GamePage.getIndexTouch(posi) == index)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool getVisible()
        {
            return isVisible;
        }
        public void setVisible(bool t)
        {
            isVisible = t;
        }
        public int getValue()
        {
            return Value;
        }
    }
}
